<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Manager
 *
 * @author miho
 */
class BluesCoders_ORM_Doctrine_Manager {

    protected $_doctrinePath;
    protected $_connectionUri;
    protected $_manager;

    public function  __construct() {
        
    }

    public function setDoctrinePath($value) {
        if(! is_dir($value)) {
            throw new Exception("Path ".$value." is not valid directory");
        }
        $this->_doctrinePath = $value;
    }

    public function setConnectionUri($value) {
        $this->_connectionUri = $value;
    }

    public function getManager() {
        if($this->_manager == null) {
            $this->_initialize();
        }

        return $this->_manager;
    }

    protected function _initialize() {
        require_once $this->_doctrinePath . '/Doctrine.php';

        spl_autoload_register(array('Doctrine','autoload'));

        $this->_manager = Doctrine_Manager::getInstance()->openConnection($this->_connectionUri);
    }

}
?>
